//
//  UserData.m
//  TowerDefence
//
//  Created by K3 on 5/29/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "PlayerData.h"
#import "iCoreGUIController.h"

@implementation PlayerData

@synthesize playerName, money, life, star;

-(id)initUserDataWith:(iCoreGUIController *)_mainGUIController {
    self = [super init];
    mainGUIController = _mainGUIController;
    [self loadUserName];
    return self;
}

-(void)loadUserName {
    if ([playerName isEqualToString:@""]) {
        playerName = @"Phai Dky";
    }
}

-(NSMutableDictionary *)convertDataToDictionary {
    NSMutableDictionary *result = [[NSMutableDictionary alloc]init];
    [result setValue:[NSString stringWithString:playerName] forKey:@"playerName"];
    //    [result setValue:[NSNumber numberWithInt:money] forKey:@"money"];
    //    [result setValue:[NSNumber numberWithInt:life] forKey:@"life"];
    [result setValue:[NSNumber numberWithInt:star] forKey:@"star"];
    
    return result;
}

-(void)loadDataFromDictionary:(NSMutableDictionary *)_data {
    playerName=[_data valueForKey:@"playerName"];
    //    money = [[_data valueForKey:@"money"] intValue];
    //    life = [[_data valueForKey:@"life"] intValue];
    star = [[_data valueForKey:@"star"] intValue];
}

@end
